
$(function() {
	validateRule();
	//打开图标列表
    $("#ico-btn").click(function(){
        layer.open({
            type: 2,
			title:'图标列表',
            content: '../../../public/FontIcoList.html',
            area: ['480px', '90%'],
            success: function(layero, index){
                //var body = layer.getChildFrame('.ico-list', index);
               // console.log(layero, index);
            }
        });
    });
});
$.validator.setDefaults({
	submitHandler : function() {
		submit01();
	}
});
function submit01() {
var params = {};
 params.name = $('#name').val();
 params.depotCode = $('#depotCode').val();
 params.depotType = $('#depotType').val();
 params.depotState = $('#depotState').val();
 params.architecture = $('#architecture').val();
 params.depotArea = $('#depotArea').val();
 params.depFloor = $('#depFloor').val();
 params.depAdmin = $('#depAdmin').val();
 params.depNumber = $('#depNumber').val();

	$.ajax({
		cache : true,
		type : "POST",
		headers:PRIVATE_HEADERS,
		dataType: 'json',
        contentType: 'application/json',
		url : API_SERVER_URL + "res/depotT/save",
		data :JSON.stringify(params) ,
		async : false,
		error : function(request) {
			laryer.alert("Connection error");
		},
		success : function(data) {
			if (data.code == 0) {
				parent.layer.msg("保存成功");
				parent.reLoad();
				var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
				parent.layer.close(index);

			} else {
				layer.alert(data.msg)
			}
		}
	});
}
function validateRule() {
	var icon = "<i class='fa fa-times-circle'></i> ";
	$("#signupForm").validate({
		rules : {
            name : {
                required : true
            },
            depotCode : {
                required : true
            },
            depotType : {
                required : true
            },
            depotState : {
                 required : true
             },
            architecture : {
                  required : true
              },
            areaName : {
               required : true
            },
            depFloor : {
                required : true
            },
            userName : {
                 required : true
            },
            depNumber : {
                 required : true
            }
        },
        messages : {
            name : {
                required : icon + "请输入库房名称"
            },
            depotCode : {
                 required : icon + "请输入库房编码"
            },
            depotType : {
                 required : icon + "请选择库房类型"
            },
            depotState : {
                 required : icon + "请选择库房状态"
            },
            architecture : {
                 required : icon + "请输入所属建筑"
            },
            areaName : {
                 required : icon + "请选择所属区域"
            },
            depFloor : {
                 required : icon + "请输入楼层"
            },
            userName : {
                 required : icon + "请选择库房管理员"
            },
            depNumber : {
                 required : icon + "请输入房间号"
            }
        }
	})
}